import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 采购记录信息 */
export interface ReportBuy {
  id: number // 编号
  processInstanceId: string // 实例ID
  buyTime: string | Dayjs // 采购日期
  deptId: number // 部门ID
  deptName: string // 接收部门
  secretType?: string // 密级
  urgencyType?: string // 紧急程度
  fileUrls: string // 文件
  sumAccount: number // 采购总额(元)
  sort?: number // 排序
  status?: number // 状态
}

// 采购记录 API
export const ReportBuyApi = {
  // 查询采购记录分页
  getReportBuyPage: async (params: any) => {
    return await request.get({ url: `/school/report-buy/page`, params })
  },

  // 查询采购记录详情
  getReportBuy: async (id: number) => {
    return await request.get({ url: `/school/report-buy/get?id=` + id })
  },

  // 新增采购记录
  createReportBuy: async (data: ReportBuy) => {
    return await request.post({ url: `/school/report-buy/create`, data })
  },

  // 修改采购记录
  updateReportBuy: async (data: ReportBuy) => {
    return await request.put({ url: `/school/report-buy/update`, data })
  },

  // 删除采购记录
  deleteReportBuy: async (id: number) => {
    return await request.delete({ url: `/school/report-buy/delete?id=` + id })
  },

  /** 批量删除采购记录 */
  deleteReportBuyList: async (ids: number[]) => {
    return await request.delete({ url: `/school/report-buy/delete-list?ids=${ids.join(',')}` })
  },

  // 导出采购记录 Excel
  exportReportBuy: async (params) => {
    return await request.download({ url: `/school/report-buy/export-excel`, params })
  }
}
